package com.atom.module.lib.opengles.util

import java.nio.*

object BufferUtils {

    fun byteBuffer(size: Int): ByteBuffer = ByteBuffer
        .allocateDirect(size * MatrixUtils.SIZE_OF_BYTE)
        .order(ByteOrder.nativeOrder())
        .also { it.limit(it.capacity()) }

    fun shortBuffer(size: Int): ShortBuffer =
        byteBuffer(size * MatrixUtils.SIZE_OF_SHORT).asShortBuffer()

    fun floatBuffer(size: Int): FloatBuffer =
        byteBuffer(size * MatrixUtils.SIZE_OF_FLOAT).asFloatBuffer()

    fun intBuffer(size: Int): IntBuffer = byteBuffer(size * MatrixUtils.SIZE_OF_INT).asIntBuffer()
}